﻿using IBLL;
using IDAL;
using Model;

namespace BLL
{
    public class zkbll:IZKBLL
    {
        public zkbll(IZKDAL<yhmodel> dal)
        {
            Dal = dal;
        }

        public IZKDAL<yhmodel> Dal { get; }

        public Task<int> Add(yhmodel y)
        {
            return Dal.AddAsync(y);
        }

        public Task<int> Delete(int id)
        {
            var res = Dal.GetAll().FirstOrDefault(p => p.Yid == id);
            return Dal.DeleteAsync(res);
        }

        public List<yhmodel> GetAll()
        {
            return Dal.GetAll().ToList();
        }

        public Task<int> Update(yhmodel y)
        {
            return Dal.UpdateAsync(y);
        }
    }
}
